package com.godyao.mall.rabbitmq;

import cn.hutool.core.lang.Snowflake;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentityGenerator;

import java.io.Serializable;

/**
 * @author godyao
 * @date 2022/4/4
 */
public class CustomIdGenerator extends IdentityGenerator {
    @Override
    public Serializable generate(SharedSessionContractImplementor s, Object obj) {
        final long workerId = new Snowflake().nextId();
        return workerId;
    }
}
